import { getToken, setToken, removeToken } from '@/utils/auth'
import { loginRequest } from '@/api/user'
export default {
  state() {
    return {
      token: getToken() || ''
    }
  },
  mutations: {
    setTokenMutations(state, payload) {
      state.token = payload
      setToken(payload)
    }
  },
  actions: {
    async getLogin({ commit }, payload) {
      const res = await loginRequest(payload)
      // console.log(res.data)
      commit('setTokenMutations', res.token)
    }
  },
  getters: {},
  namespaced: true
}
